package com.hsc.www.webFlux;

import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

import java.util.UUID;

@RestController
@RequestMapping("student")
public class StudentController {

    @GetMapping("getStudent/{id}")
    public Mono getStudent(@PathVariable  Long id)
    {
        Student student= new Student();
        student.setId(id);
        student.setName(UUID.randomUUID().toString());
        student.setAge(89);
        return Mono.just(student);
    }

    @PostMapping("postStudent")
    public Mono postStudent(@RequestBody  Student student)
    {
        return Mono.just("添加成功") ;
    }


    public static void main(String[] args) {
        Mono.just("123w")
                .map(s -> s.toUpperCase())
                .then()
                .subscribe(s->{
                    System.out.println("subscribe="+s);
                });

    }


}
